package com.example.wechat114.controller;

import com.example.wechat114.commons.JsonBean;
import com.example.wechat114.entity.Thepatients;
import com.example.wechat114.entity.WxUser;
import com.example.wechat114.service.ThepatientsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RequestMapping("thepatients")
@RestController
public class ThepatientsController {

    @Autowired
    private ThepatientsService thepatientsService;

    @PostMapping("insertThepatients")
    public JsonBean insertThepatients(Thepatients thepatients ,HttpSession session){
        WxUser userInfo = (WxUser) session.getAttribute("userInfo");
        //thepatients.setWxuseropenid(userInfo());
        return thepatientsService.addThepatiens(thepatients);
    }

    @PostMapping("getThepatients")
    public JsonBean getThepatients(Integer id){

        return thepatientsService.selectById(id);
    }

    @PostMapping("getAllThepatients")
    public JsonBean getAllThepatients(){

        return thepatientsService.selectAll();
    }

    @PostMapping("selectByidcard")
    public JsonBean selectByidcard(String idcard){
        return thepatientsService.selectByidcard(idcard);
    }

    @PostMapping("selectByopenid")
    public JsonBean selectByopenid(String openid){
        return thepatientsService.selectByopenid(openid);
    }


}
